import { Injectable } from '@angular/core';
import { _HttpClient } from '@delon/theme';
import { environment } from '@env/environment';

@Injectable({ providedIn: 'root' })

export class WeekWorkService {
    constructor(
        private http: _HttpClient,
    ) { }


    /**
     * 重置
     * "year":"2020","month":"3","weekIdx":"4"
     */
    reset(param) {
        const url = environment.project + '/ymTWa$weekplan$m/reset';
        return this.http.post(url, param);
    }

    /**
     * 周计划列表
     * orgType gq 1, cj 2,jsk 3
     * orgId 技术科查询工区的时候传车间ID
     */
    query(param) {
        const url = environment.project + '/ymTWa$weekplan$m/query';
        return this.http.get(url, param);
    }

    /**
     * 周计划审批列表
     */
    query_sp(param) {
        const url = environment.project + '/ymTWa$weekplan$m/shenpi';
        return this.http.get(url, param);
    }

    getHistory(param) {
        const url = environment.project + '/weekPlanOperator/query';
        return this.http.get(url, param);
    }

    /**
     * 删除 
     * @param ids 数组
     */
    delete(param) {
        const url = environment.project + '/ymTWa$weekplan$m/deleteBatch';
        return this.http.post(url, param);
    }

    /**
     * 审批
     * @param vcStatus 提报1 批准4 驳回3
     * @param id 选数据的N_ID,拼接 
     */
    shenpi(param) {
        // param.vcStatus = 1;
        const url = environment.apiBase + '/csmis/ymVwaMonthplan/getmonshenpi.jwt';
        return this.http.get(url, param);
    }

    /**
     * 批准
     * @param param vcStatus
     * @param param nId 用逗号分隔的id
     * @param param content 审批意见
     * 
     */
    pizhun(param) {
        const url = environment.project + '/ymTWa$weekplan$m/pass';
        return this.http.post(url, param);
    }

    /**
     * 驳回
     * @param param vcStatus
     * @param param nId 用逗号分隔的id
     * @param param content 审批意见
     */
    bohui(param) {
        const url = environment.project + '/ymTWa$weekplan$m/reject';
        return this.http.post(url, param);
    }

    /**
     * id 用逗号分隔的id
     */
    tibao(param) {
        const url = environment.project + '/ymTWa$weekplan$m/submit';
        return this.http.post(url, param);
    }

    /**
     * 根据车间查工区
     * @param yesorno 返回值带不带 请选择
     * @param orgId 车间ID
     * @param cjandgq 返回值是否包含自己 1不包含 0或不传 包含
     */
    getgongquByCjId(param) {
        const url = environment.apiBase + '/csmis/getgongquByCjId.jwt';
        return this.http.get(url, param);
    }

    getCjList() {
        const url = environment.apiBase + '/csmis/getAllChejian.jwt';
        return this.http.get(url);
    }

    // 车站
    getStationByOrgId(orgId, yesorno) {
        const url = environment.apiBase + '/csmis/getStationByOrgId2.jwt?yesorno=' + yesorno + '&orgId=' + orgId;
        return this.http.get(url);
    }

    /**
     * 根据年月周获取开始时间和结束时间，用于新增主表
     * year month weekIndex
     */
    getSdate_Edate(param) {
        const url = environment.apiBase + '/csmis/weekdefine/getByYearMonthWeek.jwt';
        return this.http.get(url, param);
    }
}